package com.mobisys.live.service;

import com.mobisys.live.dao.mapper.LiveMapper;
import com.mobisys.live.dao.model.Live;
import com.mobisys.live.dao.model.LiveWithBLOBs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LiveService {
    @Autowired
    private LiveMapper liveMapper;

    public int deleteByPrimaryKey(String id){
        return liveMapper.deleteByPrimaryKey(id);
    }

    public int insert(LiveWithBLOBs record){
        return liveMapper.insert(record);
    }

    public int insertSelective(LiveWithBLOBs record){
        return liveMapper.insertSelective(record);
    }

   public LiveWithBLOBs selectByPrimaryKey(String id){
        return liveMapper.selectByPrimaryKey(id);
   }

   public int updateByPrimaryKeySelective(LiveWithBLOBs record){
       return liveMapper.updateByPrimaryKeySelective(record);
   }

   public int updateByPrimaryKeyWithBLOBs(LiveWithBLOBs record){
       return liveMapper.updateByPrimaryKeyWithBLOBs(record);
   }

    public int updateByPrimaryKey(Live record){
       return liveMapper.updateByPrimaryKey(record);
    }

    //取出一个频道中的当前直播
    LiveWithBLOBs selectByChannelId(String channelId){
        return liveMapper.selectByChannelId(channelId);
    }
    //按类别分页查询
    public List<Live> findAll(int currPage, int pageSize, String type) {
        int currIndex = (currPage-1)*pageSize;
        return liveMapper.findAll(currIndex ,pageSize,type);
    }
    public int updateByliveId(String liveId,int status){
        return liveMapper.updateByliveId(liveId,status);
    }

}
